import javax.vecmath.*;

/**
 * @author Eric Muehlberg
 *
 *	Collision checking only perhaps?
 */
public class Cube
{
	//Center point
	Point3f pos;
	
	//Orientation in world
	Orientation o;
	
	//dimensions
	float w, h, d;
	
	//x,y,z are the coords of the center point
	public Cube(float x, float y, float z, float w, float h, float d)
	{
		
		pos = new Point3f(x,y,z);
		this.w = w;
		this.h = h;
		this.d = d;
		
		o = Orientation.xAxis;
	}
	
	/**
	 * Returns relative X coord
	 * @return
	 */
	public float getRX()
	{
		if(o == Orientation.xAxis || o == Orientation.nxAxis)
			return pos.x;
		else if(o == Orientation.zAxis || o == Orientation.nzAxis)
			return pos.z;
		else
			return 0;
	}
	
	public float getX()
	{
		return pos.x;
	}
	
	/**
	 * Returns relative width
	 * @return
	 */
	public float getRW()
	{
		if(o == Orientation.xAxis || o == Orientation.nxAxis)
			return w;
		else if(o == Orientation.zAxis || o == Orientation.nzAxis)
			return d;
		else
			return 0;
	}
	
	public float getW()
	{
		return w;
	}
	
	public float getY()
	{
		return pos.y;
	}
	
	public float getZ()
	{
		return pos.z;
	}
	
	public float getH()
	{
		return h;
	}
	
	public float getD()
	{
		return d;
	}
	
	public Orientation getO()
	{
		return o;
	}
	
	public void updateX(float x)
	{
		if(o == Orientation.xAxis || o == Orientation.nxAxis)
		{
			pos.x += x;
		}
		else if(o == Orientation.zAxis || o == Orientation.nzAxis)
		{
			pos.z += x;
		}
	}
	
	public void updateY(float y)
	{
		pos.y -= y;
	}
	
	public void updateRZ(float z)
	{
		if(o == Orientation.xAxis || o == Orientation.nxAxis)
		{
			pos.z = z;
		}
		else if(o == Orientation.zAxis || o == Orientation.nzAxis)
		{
			pos.x = z;
		}
	}
	
	public float getRZ()
	{
		if(o == Orientation.xAxis)
			return pos.z;
		else if(o == Orientation.nxAxis)
			return -pos.z;
		else if(o == Orientation.zAxis)
			return pos.x;
		else if(o == Orientation.nzAxis)
			return -pos.x;
		else
			return 0;
	}
	
	/**
	 * Changes the characters orientation to the respective plane
	 * via a 90 degree rotation of the level to the left.
	 */
	public void snapleft()
	{
		switch(o)
		{
		case xAxis:
			o = Orientation.nzAxis;
			break;
		case nxAxis:
			o = Orientation.zAxis;
			break;
		case zAxis:
			o = Orientation.xAxis;
			break;
		case nzAxis:
			o = Orientation.nxAxis;
			break;
		}
	}
	
	/**
	 * Changes the characters orientation to the respective plane
	 * via a 90 degree rotation of the level to the right.
	 */
	public void snapright()
	{
		switch(o)
		{
		case xAxis:
			o = Orientation.zAxis;
			break;
		case nxAxis:
			o = Orientation.nzAxis;
			break;
		case zAxis:
			o = Orientation.nxAxis;
			break;
		case nzAxis:
			o = Orientation.xAxis;
			break;
		}
	}
}
